from python_baway.common.xcommon import sep

with open('test_write.tmp.txt', 'a+') as f:

    def xwrite(str):
        n = f.write(str)
        print(f'Writen {n} chars')

    xwrite('Hello(你好)')
    xwrite(' world(世界)!(！)\n')

    def xwritelines(arr):
        n = f.writelines(arr)
        print(f'Writen {n} chars')

    xwritelines(('Apple\n', 'Bus\n', 'Car\n', 'Dog\n'))
    xwritelines('Apple is good for your healthy.\n')

    sep('Read it')
    f.seek(0)
    cont = f.read()
    print(cont)